var a = require("../../../../@babel/runtime/helpers/defineProperty"), t = getApp();

Page({
    data: {
        language: "",
        uploadUrl: "upload.uploadPic",
        order_pay_id: "",
        imageUrl: "",
        upImgSrc: "",
        status: "",
        order_ids: ""
    },
    onLoad: function(a) {
        a.id && this.setData({
            order_pay_id: a.id
        }), a.status && this.setData({
            status: a.status
        }), a.order_ids && this.setData({
            order_ids: a.order_ids
        }), this.getJson();
    },
    onReady: function() {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        });
    },
    onShow: function() {},
    copyText: function(a) {
        var t = a.currentTarget.dataset.text;
        wx.setClipboardData({
            data: t
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getJson: function() {
        var e = this;
        this.setData({
            imageUrl: "",
            upImgSrc: ""
        });
        var o = "";
        o += t.getNetAddresss("order.merge-pay.dcm-scan-pay"), o += "&order_pay_id=" + this.data.order_pay_id, 
        t._getNetWork({
            url: o,
            success: function(t) {
                var o = t.data;
                if (1 == o.result) {
                    e.setData({
                        bank_info: o.data.payee_info,
                        amount_info: o.data.amount,
                        pay_info: o.data.pay_sn
                    });
                    var n = o.data.payee_info.information;
                    n = n.replace(/<img/g, '<img style="width:100%"'), e.setData(a({}, "bank_info.information", n));
                }
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    onRead: function() {
        var a = this, e = t.getNetAddresss(this.data.uploadUrl);
        wx.chooseImage({
            count: 1,
            sizeType: [ "original", "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(t) {
                var o = t.tempFilePaths;
                wx.compressImage({
                    src: o[0],
                    quality: 60,
                    success: function(t) {
                        var o = t.tempFilePath;
                        wx.uploadFile({
                            url: e,
                            filePath: o,
                            name: "file",
                            success: function(t) {
                                var e = JSON.parse(t.data);
                                1 == e.result ? a.setData({
                                    imageUrl: o,
                                    upImgSrc: e.data.img
                                }) : wx.showToast({
                                    icon: "none",
                                    title: e.msg,
                                    duration: 1500
                                });
                            }
                        });
                    },
                    fail: function(a) {},
                    complete: function(a) {}
                });
            }
        });
    },
    confirmEvent: function() {
        if ("" != this.data.upImgSrc) {
            var a = this, e = t.getNetAddresss("plugin.dcm-scan-pay.frontend.pay");
            e += "&order_pay_id=" + this.data.order_pay_id, e += "&report_url=" + this.data.upImgSrc, 
            t._getNetWork({
                url: e,
                success: function(t) {
                    var e = t.data;
                    1 == e.result && wx.showToast({
                        title: e.msg,
                        icon: "none",
                        duration: 1500,
                        success: function() {
                            setTimeout(function() {
                                wx.navigateTo({
                                    url: "/packageA/member/myOrder_v2/myOrder_v2?status=2&bank_id=" + a.data.order_pay_id
                                });
                            }, 1500);
                        }
                    });
                },
                fail: function(a) {
                    console.log(a);
                }
            });
        } else wx.showToast({
            icon: "none",
            title: "请上传付款凭证",
            duration: 1500
        });
    },
    onLine: function() {
        wx.redirectTo({
            url: "/packageD/buy/orderPay/orderPay?status=" + this.data.status + "&order_id=" + this.data.order_ids
        });
    }
});